#ifndef SVM_TRAINER_H
#define SVM_TRAINER_H

#include <opencv2/opencv.hpp>
#include <opencv2/ml.hpp>
#include <vector>
#include <string>

class SVMTrainer {
public:
    SVMTrainer();
    bool loadDataset(const std::string& dataset_path);
    bool trainModel(const std::string& model_save_path);
    void setTrainTestSplit(double train_ratio = 0.8);
    double evaluateModel(const cv::Ptr<cv::ml::SVM>& svm);
    
private:
    cv::Mat train_features_;
    cv::Mat train_labels_;
    cv::Mat test_features_;
    cv::Mat test_labels_;
    
    cv::Mat all_features_;
    cv::Mat all_labels_;
    
    void loadImagesFromDirectory(const std::string& dir_path, int label);
    cv::Mat preprocessImage(const cv::Mat& image);
};

#endif